using System.IO;
using HQLAddin.Highlighting;
using HQLAddin.Tests.SnapshotUtils;
using Microsoft.VisualStudio.Text;
using NUnit.Framework;
using SharpTestsEx;

namespace HQLAddin.Tests.Highlighting
{
	[TestFixture]
	public class SnapshotExtensionsTests
	{
		private static readonly string[] ExampleWithBadQueries = File.ReadAllLines("examples\\example-with-badqueries.xml");

		[Test]
		public void WhenCallingGetQueryWithSnapshotNotPointingToNotQueryLineReturnNull()
		{
			var snapshot = SnapshotUtil.CreateSnapshot(ExampleWithBadQueries);
			snapshot.GetQueryInfoAtLine(10).Should().Be.Null();
		}

		[Test]
		public void WhenCallingGetQueryWithSnapshotPointingToQueryLineThenReturnQuery()
		{
			var snapshot = SnapshotUtil.CreateSnapshot(ExampleWithBadQueries);
			snapshot.GetQueryInfoAtLine(21).Satisfy(q => q.Query.Contains("from Foo where where f.id = 1"));
		}
	}
}